<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>筛选数组</title>
</head>
<body>
    <script>
        // 筛选出数组中大于10的数
        // 方法1
        var arr = [2,15,25,6,8,30,35,95,64];
        var newArr = [];
        var j = 0;
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
                newArr[j] = arr[i];
                j++;
            }   
        }
        console.log(newArr);
        // 方法2
        var arr = [2,15,25,6,8,30,35,95,64];
        var newArr = [];
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
                newArr[newArr.length] = arr[i];
            }   
        }
        console.log(newArr);
    </script>
</body>
</html>